import 'package:flutter/material.dart';
import 'package:shop_app/pages/cart/cart_page.dart';
import 'package:shop_app/pages/category/category_page.dart';
import 'package:shop_app/pages/home/home_page.dart';
import 'package:shop_app/pages/mine/mine_page.dart';

class RootPage extends StatefulWidget {
  const RootPage({super.key});

  @override
  State<RootPage> createState() => _RootPageState();
}

class _RootPageState extends State<RootPage> {
  ///页面列表
  List pages = [HomePage(), CategoryPage(), CartPage(), MinePage()];
  int _curringIndex = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: pages[_curringIndex],
      bottomNavigationBar: Theme(
        data: ThemeData(
          //去掉水波纹效果
          splashColor: Colors.transparent,
          highlightColor: Colors.transparent,
        ),
        child: BottomNavigationBar(
          selectedItemColor: Colors.red,
          unselectedItemColor: Colors.black,
          selectedFontSize: 12,
          unselectedFontSize: 10,
          currentIndex: _curringIndex,
          onTap: (index) {
            setState(() {
              _curringIndex = index;
            });
          },
          type: BottomNavigationBarType.fixed,
          items: [
            BottomNavigationBarItem(icon: Icon(Icons.home), label: "首页"),
            BottomNavigationBarItem(icon: Icon(Icons.category), label: "分类"),
            BottomNavigationBarItem(
              icon: Icon(Icons.shopping_cart),
              label: "购物车",
            ),
            BottomNavigationBarItem(icon: Icon(Icons.person), label: "我的"),
          ],
        ),
      ),
    );
  }
}
